﻿using System;
using System.Web.UI;

namespace Hxsoft.AppV1._Controls
{
	public partial class UpdateProgress : Hxsoft.AppV1.UserControl
	{
		protected string ProgressText
		{
			get { return Res.UpdateProgress_ProgressText; }
		}

		private LoadedValue<int> loadedDisplayAfter;
		public int DisplayAfter
		{
			get
			{
				if (loadedDisplayAfter.Loader == null)
					loadedDisplayAfter.Loader = () => IntExtensions.ConvertFromOrDefault(ViewState["DisplayAfter"], 0);
				return loadedDisplayAfter.Value;
			}
			set
			{
				if (loadedDisplayAfter.Setter == null)
					loadedDisplayAfter.Setter = v => ViewState["DisplayAfter"] = v;
				loadedDisplayAfter.Value = value;
			}
		}

		public string GetAssociatedUpdatePanelID()
		{
			return AssociatedUpdatePanelID == null ? "null" : @"""" + AssociatedUpdatePanelID + @"""";
		}

		private LoadedValue<string> loadedAssociatedUpdatePanelID;
		public string AssociatedUpdatePanelID
		{
			get
			{
				if (loadedAssociatedUpdatePanelID.Loader == null)
					loadedAssociatedUpdatePanelID.Loader = () => (string)ViewState["AssociatedUpdatePanelID"];
				return loadedAssociatedUpdatePanelID.Value;
			}
			set
			{
				if (loadedAssociatedUpdatePanelID.Setter == null)
					loadedAssociatedUpdatePanelID.Setter = v => ViewState["AssociatedUpdatePanelID"] = v;
				loadedAssociatedUpdatePanelID.Value = value;
			}
		}

		protected override void OnPreRender(EventArgs e)
		{
			this.ApplicationPage.RegisterHeadIncludeFile(ApplicationConfiguration.JQueryUrl, IncludeFileType.JS);
			this.ApplicationPage.RegisterHeadIncludeFile(ApplicationConfiguration.JQueryBlockUIUrl, IncludeFileType.JS);
			this.ApplicationPage.RegisterHeadIncludeFile(ApplicationConfiguration.UpdateProgressStyleUrl, IncludeFileType.CSS);

			base.OnPreRender(e);
		}
	}
}